package org.skipper.sms.config;

import org.skipper.sms.AliyunSmsService;
import org.skipper.sms.domain.AliyunSmsProperties;
import org.skipper.sms.impl.AliyunSmsServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author shoujian
 * Date: 2024-03-07
 * Time: 15:16
 */
@Configuration
@EnableConfigurationProperties(AliyunSmsProperties.class)
public class AliyunSmsAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public AliyunSmsService aliyunOssService(AliyunSmsProperties properties) {
        AliyunSmsServiceImpl fileStorageServiceOss = new AliyunSmsServiceImpl();
        fileStorageServiceOss.setAccessKeyId(properties.getAccessKeyId());
        fileStorageServiceOss.setAccessKeySecret(properties.getAccessKeySecret());
        return fileStorageServiceOss;
    }

}
